From 35a7006a03755a71acb86273df3f6176c935ac97 Mon Sep 17 00:00:00 2001 From: Mohd Tarmizi Date: Tue, 14 Apr 2015 01:44:20 +0800 Subject: [PATCH] Rewrite for readability --- src/cargo/ops/cargo_rustc/context.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index c7cfbfe77..3fcf058de 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -338,23 +338,24 @@ impl<'a, 'b: 'a> Context<'a, 'b> { Some(deps) => deps, }; let mut ret = deps.map(|id| self.get_package(id)).filter(|dep| { - let pkg_dep = pkg.dependencies().iter().find(|d| { - d.name() == dep.name() && + pkg.dependencies().iter().filter(|d| { + d.name() == dep.name() + }).any(|d| { // If this target is a build command, then we only want build // dependencies, otherwise we want everything *other than* build // dependencies. - target.is_custom_build() == d.is_build() && + let is_correct_dep = target.is_custom_build() == d.is_build(); // If this dependency is *not* a transitive dependency, then it // only applies to test/example targets - (d.is_transitive() || - target.is_test() || - target.is_example() || - profile.test) - }); + let is_actual_dep = d.is_transitive() || + target.is_test() || + target.is_example() || + profile.test; - pkg_dep.is_some() + is_correct_dep && is_actual_dep + }) }).filter_map(|pkg| { pkg.targets().iter().find(|t| t.is_lib()).map(|t| { (pkg, t, self.lib_profile(pkg.package_id())) -- 2.30.2